package com.lizhen.behaviorpattern.visitorpattern.impl;

import com.lizhen.behaviorpattern.visitorpattern.ComputerPart;
import com.lizhen.behaviorpattern.visitorpattern.ComputerPartVisitor;

public class Computer implements ComputerPart {
    ComputerPart[] parts = new ComputerPart[]{new Mouse(), new Keyboard(), new Monitor()};

    public Computer() {
    }

    public void accept(ComputerPartVisitor computerPartVisitor) {
        for (int i = 0; i < this.parts.length; ++i) {
            this.parts[i].accept(computerPartVisitor);
        }

        computerPartVisitor.visit(this);
    }
}
